package org.example.servicemanage.thread;

import org.example.servicemanage.client.WXFeignClient;
import org.example.servicemanage.config.YmlConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WXTokenThread implements Runnable{

    @Autowired
    private WXFeignClient wxFeignClient;

    @Override
    public void run() {
        while (true) {
            YmlConfig.WX_TOKEN = wxFeignClient.getToken(YmlConfig.WX_GRANT_TYPE, YmlConfig.WX_APPID, YmlConfig.WX_SECRET).getAccess_token();
            try {
                this.wait(540000L);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
